<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加品牌</title>
</head>
<body>

<script src="js/axios-0.18.0.js"></script>
<script src="js/vue.js"></script>
<h3>添加品牌</h3>



<div id="add">


    <form action="" method="post">
        品牌名称：<input id="brandName" name="brandName" v-model="brands.brandName"><br>
        企业名称：<input id="companyName" name="companyName" v-model="brands.companyName"><br>
        排序：<input id="ordered" name="ordered" v-model="brands.ordered"><br>
        描述信息：<textarea rows="5" cols="20" id="description" name="description" v-model="brands.description"></textarea><br>
        状态：
        <input type="radio" name="status" value="0" v-model="brands.status">禁用
        <input type="radio" name="status" value="1" v-model="brands.status">启用<br>

        <input type="button" id="btn" value="提交" v-on:click="show()">
    </form>

</div>


<script>
    new Vue({
        el: "#add",
        data:{
            brands:{}
        },
        methods:{
            show(){
                var brands = this.brands;
                axios({
                    method: "post",
                    url: "http://localhost:8080/brand-demo2/addBrand",
                    data: brands
                }).then(resp => {
                    if (resp.data == "succes") {
                        location.href="http://localhost:8080/brand-demo2/brand.html";
                    }
                })
            }

        }

    })


    /*
    document.getElementById("btn").onclick = function () {
        var f ={
            brandName:"",
            companyName:"",
            ordered:"",
            description:"",
            status:""
        }

        let brandName = document.getElementById("brandName").value;
        f.brandName = brandName;

        let companyName = document.getElementById("companyName").value;
        f.companyName = companyName;

        let ordered = document.getElementById("ordered").value;
        f.ordered = ordered;

        let description = document.getElementById("description").value;
        f.description = description;

        let status = document.getElementsByName("status");
        for (let i = 0; i < status.length; i++) {
            if (status[i].checked) {
                f.status = status[i].value;
            }
        }

        axios({
            method: "post",
            url: "http://localhost:8080/brand-demo2/addBrand",
            data: f
        }).then(function (resp) {
            if (resp.data == "succes") {
                location.href="http://localhost:8080/brand-demo2/brand.html";
                //document.getElementById("btn").type = "submit"
            }
        })
    }
*/
</script>


</body>
</html>





